IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'spArchives_Create')
	BEGIN
		PRINT 'Dropping Procedure spArchives_Create'
		DROP  Procedure  spArchives_Create
	END

GO

PRINT 'Creating Procedure spArchives_Create'
GO
CREATE Procedure dbo.spArchives_Create
	( 	  
	  @CreatedByUser_ID numeric(9,0) = null, 
		@ArchiveDate DateTime = null, 
		@ArchiveStatus varchar(50) = null, 
		@DivisionName varchar(50) = null, 
		@DepartmentName varchar(50) = null, 
		@AttachedFile image = null, 
		@Comments varchar(250) = null, 
		@DestructionDate DateTime = null, 
		@Shred bit = null, 
		@NoShredReason varchar(100) = null, 
		@CurrentLocation varchar(100) = null, 
		@DeliveryCollection varchar(100) = null, 
		@DueDate DateTime = null, 
		@ApprovedUser_ID numeric(9,0) = null, 
		@ApprovedDate DateTime = null, 
		@ReceivedbyUser_ID numeric(9,0) = null, 
		@ReceivedDate DateTime = null, 
		@ClosedByUser_ID numeric(9,0) = null, 
		@ClosedDate DateTime = null
	)
AS
  /* 
    ------------------------------------------------------------------------------
    - Change History
    - --------------
    - Date          Description
    ------------------------------------------------------------------------------
    - 2007/11/02    Initial version created
    ------------------------------------------------------------------------------
  */

	-- Declare the required variables

	-- Create the required new record
	INSERT INTO Archives
	  (
		CreatedByUser_ID,
			ArchiveDate,
			ArchiveStatus,
			DivisionName,
			DepartmentName,
			AttachedFile,
			Comments,
			DestructionDate,
			Shred,
			NoShredReason,
			CurrentLocation,
			DeliveryCollection,
			DueDate,
			ApprovedUser_ID,
			ApprovedDate,
			ReceivedbyUser_ID,
			ReceivedDate,
			ClosedByUser_ID,
			ClosedDate	  
	  )
	VALUES
	  (
		@CreatedByUser_ID,
			@ArchiveDate,
			@ArchiveStatus,
			@DivisionName,
			@DepartmentName,
			@AttachedFile,
			@Comments,
			@DestructionDate,
			@Shred,
			@NoShredReason,
			@CurrentLocation,
			@DeliveryCollection,
			@DueDate,
			@ApprovedUser_ID,
			@ApprovedDate,
			@ReceivedbyUser_ID,
			@ReceivedDate,
			@ClosedByUser_ID,
			@ClosedDate
	  )

	-- Handle any errors
	IF @@ERROR != 0
	BEGIN
		RAISERROR('spArchives_Create: Unable to Insert a new Archives', 10, 1)
		RETURN
	END

	-- Return the newly created ID
	SELECT	@@IDENTITY AS 'Archives_ID'

	-- Return to calling method
	RETURN 

GO
